/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.ossr.portlets.pm.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.ossr.portlets.pm.model.PrivateMessage;
import org.ossr.portlets.pm.model.PrivateMessageModel;
import org.ossr.portlets.pm.model.PrivateMessageSoap;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the PrivateMessage service. Represents a row in the &quot;model_PrivateMessage&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.ossr.portlets.pm.model.PrivateMessageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PrivateMessageImpl}.
 * </p>
 *
 * <p>
 * Never modify or reference this class directly. All methods that expect a private message model instance should use the {@link org.ossr.portlets.pm.model.PrivateMessage} interface instead.
 * </p>
 *
 * @author Edgar Zavala
 * @see PrivateMessageImpl
 * @see org.ossr.portlets.pm.model.PrivateMessage
 * @see org.ossr.portlets.pm.model.PrivateMessageModel
 * @generated
 */
public class PrivateMessageModelImpl extends BaseModelImpl<PrivateMessage>
	implements PrivateMessageModel {
	public static final String TABLE_NAME = "model_PrivateMessage";
	public static final Object[][] TABLE_COLUMNS = {
			{ "messageId", new Integer(Types.BIGINT) },
			{ "ownerId", new Integer(Types.BIGINT) },
			{ "recepients", new Integer(Types.VARCHAR) },
			{ "creationDate", new Integer(Types.TIMESTAMP) },
			{ "isReply", new Integer(Types.BOOLEAN) },
			{ "replyDate", new Integer(Types.TIMESTAMP) },
			{ "deleted", new Integer(Types.BOOLEAN) },
			{ "readed", new Integer(Types.BOOLEAN) },
			{ "subject", new Integer(Types.VARCHAR) },
			{ "body", new Integer(Types.VARCHAR) }
		};
	public static final String TABLE_SQL_CREATE = "create table model_PrivateMessage (messageId LONG not null primary key IDENTITY,ownerId LONG,recepients VARCHAR(75) null,creationDate DATE null,isReply BOOLEAN,replyDate DATE null,deleted BOOLEAN,readed BOOLEAN,subject VARCHAR(75) null,body TEXT null)";
	public static final String TABLE_SQL_DROP = "drop table model_PrivateMessage";
	public static final String ORDER_BY_JPQL = " ORDER BY privateMessage.creationDate ASC";
	public static final String ORDER_BY_SQL = " ORDER BY model_PrivateMessage.creationDate ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.org.ossr.portlets.pm.model.PrivateMessage"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.org.ossr.portlets.pm.model.PrivateMessage"),
			true);

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static PrivateMessage toModel(PrivateMessageSoap soapModel) {
		PrivateMessage model = new PrivateMessageImpl();

		model.setMessageId(soapModel.getMessageId());
		model.setOwnerId(soapModel.getOwnerId());
		model.setRecepients(soapModel.getRecepients());
		model.setCreationDate(soapModel.getCreationDate());
		model.setIsReply(soapModel.getIsReply());
		model.setReplyDate(soapModel.getReplyDate());
		model.setDeleted(soapModel.getDeleted());
		model.setReaded(soapModel.getReaded());
		model.setSubject(soapModel.getSubject());
		model.setBody(soapModel.getBody());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<PrivateMessage> toModels(PrivateMessageSoap[] soapModels) {
		List<PrivateMessage> models = new ArrayList<PrivateMessage>(soapModels.length);

		for (PrivateMessageSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.org.ossr.portlets.pm.model.PrivateMessage"));

	public PrivateMessageModelImpl() {
	}

	public long getPrimaryKey() {
		return _messageId;
	}

	public void setPrimaryKey(long pk) {
		setMessageId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_messageId);
	}

	public long getMessageId() {
		return _messageId;
	}

	public void setMessageId(long messageId) {
		_messageId = messageId;
	}

	public long getOwnerId() {
		return _ownerId;
	}

	public void setOwnerId(long ownerId) {
		_ownerId = ownerId;
	}

	public String getRecepients() {
		if (_recepients == null) {
			return StringPool.BLANK;
		}
		else {
			return _recepients;
		}
	}

	public void setRecepients(String recepients) {
		_recepients = recepients;
	}

	public Date getCreationDate() {
		return _creationDate;
	}

	public void setCreationDate(Date creationDate) {
		_creationDate = creationDate;
	}

	public boolean getIsReply() {
		return _isReply;
	}

	public boolean isIsReply() {
		return _isReply;
	}

	public void setIsReply(boolean isReply) {
		_isReply = isReply;
	}

	public Date getReplyDate() {
		return _replyDate;
	}

	public void setReplyDate(Date replyDate) {
		_replyDate = replyDate;
	}

	public boolean getDeleted() {
		return _deleted;
	}

	public boolean isDeleted() {
		return _deleted;
	}

	public void setDeleted(boolean deleted) {
		_deleted = deleted;
	}

	public boolean getReaded() {
		return _readed;
	}

	public boolean isReaded() {
		return _readed;
	}

	public void setReaded(boolean readed) {
		_readed = readed;
	}

	public String getSubject() {
		if (_subject == null) {
			return StringPool.BLANK;
		}
		else {
			return _subject;
		}
	}

	public void setSubject(String subject) {
		_subject = subject;
	}

	public String getBody() {
		if (_body == null) {
			return StringPool.BLANK;
		}
		else {
			return _body;
		}
	}

	public void setBody(String body) {
		_body = body;
	}

	public PrivateMessage toEscapedModel() {
		if (isEscapedModel()) {
			return (PrivateMessage)this;
		}
		else {
			return (PrivateMessage)Proxy.newProxyInstance(PrivateMessage.class.getClassLoader(),
				new Class[] { PrivateMessage.class },
				new AutoEscapeBeanHandler(this));
		}
	}

	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					PrivateMessage.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	public Object clone() {
		PrivateMessageImpl privateMessageImpl = new PrivateMessageImpl();

		privateMessageImpl.setMessageId(getMessageId());

		privateMessageImpl.setOwnerId(getOwnerId());

		privateMessageImpl.setRecepients(getRecepients());

		privateMessageImpl.setCreationDate(getCreationDate());

		privateMessageImpl.setIsReply(getIsReply());

		privateMessageImpl.setReplyDate(getReplyDate());

		privateMessageImpl.setDeleted(getDeleted());

		privateMessageImpl.setReaded(getReaded());

		privateMessageImpl.setSubject(getSubject());

		privateMessageImpl.setBody(getBody());

		return privateMessageImpl;
	}

	public int compareTo(PrivateMessage privateMessage) {
		int value = 0;

		value = DateUtil.compareTo(getCreationDate(),
				privateMessage.getCreationDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		PrivateMessage privateMessage = null;

		try {
			privateMessage = (PrivateMessage)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = privateMessage.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(21);

		sb.append("{messageId=");
		sb.append(getMessageId());
		sb.append(", ownerId=");
		sb.append(getOwnerId());
		sb.append(", recepients=");
		sb.append(getRecepients());
		sb.append(", creationDate=");
		sb.append(getCreationDate());
		sb.append(", isReply=");
		sb.append(getIsReply());
		sb.append(", replyDate=");
		sb.append(getReplyDate());
		sb.append(", deleted=");
		sb.append(getDeleted());
		sb.append(", readed=");
		sb.append(getReaded());
		sb.append(", subject=");
		sb.append(getSubject());
		sb.append(", body=");
		sb.append(getBody());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(34);

		sb.append("<model><model-name>");
		sb.append("org.ossr.portlets.pm.model.PrivateMessage");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>messageId</column-name><column-value><![CDATA[");
		sb.append(getMessageId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ownerId</column-name><column-value><![CDATA[");
		sb.append(getOwnerId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>recepients</column-name><column-value><![CDATA[");
		sb.append(getRecepients());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>creationDate</column-name><column-value><![CDATA[");
		sb.append(getCreationDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isReply</column-name><column-value><![CDATA[");
		sb.append(getIsReply());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>replyDate</column-name><column-value><![CDATA[");
		sb.append(getReplyDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>deleted</column-name><column-value><![CDATA[");
		sb.append(getDeleted());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>readed</column-name><column-value><![CDATA[");
		sb.append(getReaded());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>subject</column-name><column-value><![CDATA[");
		sb.append(getSubject());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>body</column-name><column-value><![CDATA[");
		sb.append(getBody());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _messageId;
	private long _ownerId;
	private String _recepients;
	private Date _creationDate;
	private boolean _isReply;
	private Date _replyDate;
	private boolean _deleted;
	private boolean _readed;
	private String _subject;
	private String _body;
	private transient ExpandoBridge _expandoBridge;
}